﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using Rison.Web.Common;
using Rison.BusinessFacade.Facade.Biz;

namespace Rison.Web.wscp
{
    public partial class CPDepartmentList : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                BindDepartments();
            }
        }

        private void BindDepartments()
        {
            CPResultDetailFacade facade = new CPResultDetailFacade();
            
            DataSet data = facade.GetDepartments("Category.CategoryName='党群部门'");
            this.dlstDepart1.DataSource = data.Tables[0].DefaultView;
            this.dlstDepart1.DataBind();

            data = facade.GetDepartments("Category.CategoryName='政府部门及司法部门'");
            this.dlstDepart2.DataSource = data.Tables[0].DefaultView;
            this.dlstDepart2.DataBind();

            data = facade.GetDepartments("Category.CategoryName='街道、镇'");
            this.dlstDepart3.DataSource = data.Tables[0].DefaultView;
            this.dlstDepart3.DataBind();


            ////部门
            //this.dlstDepart1.DataSource = data.Tables[0].DefaultView;
            //this.dlstDepart1.DataBind();

            //DataTable departs1 = new DataTable();
            //departs1.Columns.Add("bmid", typeof(System.String));
            //departs1.Columns.Add("bmmc", typeof(System.String));

            //DataTable departs2 = departs1.Clone();
            //DataTable departs3 = departs1.Clone();

            //DataRow row = null;

            //for (int i = 1; i < 64; i++)
            //{
            //    if (i < 22)
            //    {
            //        row = departs1.NewRow(); departs1.Rows.Add(row);
            //    }
            //    else if (i < 43)
            //    {
            //        row = departs2.NewRow(); departs2.Rows.Add(row);
            //    }
            //    else
            //    {
            //        row = departs3.NewRow(); departs3.Rows.Add(row);
            //    }

            //    row["bmid"] = "466fbbdf-9d21-4203-9c48-d761e30be2cc";// i.ToString();
            //    row["bmmc"] = "呀呀呸的部门_" + i.ToString();
            //}

            //this.dlstDepart1.DataSource = departs1.DefaultView;
            //this.dlstDepart1.DataBind();
            //this.dlstDepart2.DataSource = departs2.DefaultView;
            //this.dlstDepart2.DataBind();
            //this.dlstDepart3.DataSource = departs3.DefaultView;
            //this.dlstDepart3.DataBind();
        }

        protected void btnBack_Click(object sender, EventArgs e)
        {
            Response.Redirect("../Default.aspx");
        }

    }
}
